home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / position < prev    next >
Text File  |  2006-10-19  |  5KB  |  188 lines

  1. ************************************************************
  2. *                                                          *
  3. *  Procedure POSIT - POSITION                              *
  4. *                                                          *
  5. *  This procedure will take the record number speficied    *
  6. *  in the PAB and position the file pointers at that       *
  7. *  record.  If there is currently information in the       *
  8. *  file buffer, it will call FLUSH before reading in       *
  9. *  the new information.                                    *
  10. *                                                          *
  11. ************************************************************
  12.  
  13. POSERR BL   @DSRERR
  14.        DATA >0500            Attempt to read past EOF
  15.  
  16. POSIT
  17.        LDCR @ZERO,4          Select RAM bank 0
  18.        MOV  @PABBUF+6,R10    Get record number we want to read
  19.  
  20.        LDCR @B02,4           Select RAM bank 2
  21.        MOV  R11,@POSIRT      Save return address
  22.        BLWP @IFO
  23.        MOV  @4(R5),R1        Get FDR address
  24.        LDCR @2(R5),4         Select bank with FDR
  25.        MOV  @18(R1),R0       Get # of records in file
  26.        SWPB R0
  27.        C    R10,R0
  28.        JHE  POSERR
  29.  
  30.        LDCR @B02,4           Select RAM bank 2
  31.        MOV  R10,@62(R5)      Save record number
  32.        LDCR @2(R5),4         Select bank with FDR
  33.  
  34. * Now divide by number of records per sector to get the
  35. * sector offset into the file.
  36. *
  37.        MOVB @13(R1),R0
  38.        SRL  R0,8
  39.        CLR  R9
  40.        DIV  R0,R9
  41.  
  42. * Now R10 has the record number in the sector.
  43. *     R9  has the sector in the file
  44.  
  45. * We now divide R9 by the number of sectors per
  46. * AU to get an AU number and sector within AU
  47.  
  48.        CLR  R8
  49.        LDCR @B04,4           Select RAM bank 4
  50.        MOV  R6,R3
  51.        SRL  R3,8
  52.        SLA  R3,1
  53.        DIV  @SAUTBL(R3),R8
  54.  
  55. * Now R9 has the sector within AU.
  56. *     R8 has the AU
  57.  
  58. * Now we have to go through the data chain and map
  59. * the AU in the file to the AU on the disk.
  60.  
  61.        LDCR @B02,4           Select RAM bank 2
  62.        LDCR @2(R5),4         Select BANK with FDR
  63.        AI   R1,40            Point to data chain
  64.  
  65. POSIT1 MOV  *R1+,R2          Get AU from data chain
  66. POSIT2 CI   R8,0             See if we're at the AU we want
  67.        JEQ  POSIT4
  68.        DEC  R8
  69.        C    R2,*R1           See if we're at last AU in cluster
  70.        JEQ  POSIT3
  71.        INC  R2               If not, go to next one
  72.        JMP  POSIT2
  73.  
  74. POSIT3 INCT R1               Point to next entry in chain
  75.        JMP  POSIT1
  76.  
  77. * R2 has the AU we need.  If it's not in our buffer, we have
  78. * to read it from the disk.
  79.  
  80. POSIT4 LDCR @B02,4           Select RAM bank 2
  81.        MOV  @6(R5),@54(R5)   Reset pointer in buffer
  82.        C    R2,@50(R5)       See what AU is in the buffer
  83.        JNE  POSIT5
  84.        C    R9,@52(R5)       See if right sector within AU
  85.        JEQ  POSI13
  86.        C    @58(R5),@ZERO    If we have a 512 byte buffer,
  87.        JEQ  POSIT5           we may still be in luck
  88.  
  89.        AB   @B01,@54(R5)
  90.        MOV  R9,R0
  91.        DEC  R0
  92.        C    R0,@52(R5)
  93.        JEQ  POSI13
  94.  
  95. * We have to read the sector from the disk
  96. *
  97.  
  98. POSIT5
  99.        MOV  R2,@POSIAU       Save new AU
  100.        MOV  R9,@POSISE       Save new sector in AU
  101.        BL   @FLUSH
  102.        LDCR @B02,4
  103.        MOV  @POSIAU,R7       Restore AU
  104.        MOV  @POSISE,R9       Restore sector within AU
  105.  
  106.        MOV  R7,@50(R5)       Save AU
  107.        MOV  R9,@52(R5)       Save sector within AU
  108.        MOV  @6(R5),@54(R5)   Reset pointer in buffer
  109.  
  110.        LI   R1,SECBUF
  111.        LDCR @B04,4           Select RAM bank 4
  112.        MOV  R6,R3
  113.        SRL  R3,8
  114.        SLA  R3,1
  115.        MOV  @SAUTBL(R3),R3
  116.        MPY  R3,R7
  117.        A    R9,R8
  118.        JNC  POSIT6
  119.        INC  R7
  120. POSIT6 SRL  R8,1
  121.        JNC  POSIT7
  122.        AI   R1,>100
  123. POSIT7 SRL  R7,1
  124.        JNC  POSIT8
  125.        AI   R8,>8000
  126. POSIT8 LDCR @ZERO,4
  127.        BLWP @BANKIT
  128.        DATA SCSIRD
  129.        JEQ  POSIT9
  130.        BL   @DSRERR
  131.        DATA >0600            Device error
  132.  
  133. POSIT9 LDCR @B02,4
  134.        CLR  @58(R5)          Set buffer size=256
  135.  
  136. * Now see if we can use a 512 byte buffer.  We can make
  137. * this check a little more sophisticated by checking
  138. * if R1 = SECBUF+256, we may be able to back it up
  139. * to SECBUF and adjust pointer within sector and
  140. * sector within AU accordingly
  141. *
  142.        MOV  @POSISE,R9
  143.        CI   R1,SECBUF        Make sure we start out
  144.        JNE  POSI14
  145.        S    R9,R3
  146.        CI   R3,1
  147.        JEQ  POSI11
  148. POSI10 SETO @58(R5)          Set buffer size=512
  149. POSI11
  150.        MOV  @6(R5),R3        Get buffer address
  151.        MOVB @3(R5),R2        Get buffer bank
  152. POSI12 LDCR @ZERO,4
  153.        MOV  *R1+,R4
  154.        MOV  *R1+,R7
  155.        MOV  *R1+,R8
  156.        MOV  *R1+,R9
  157.        LDCR R2,4
  158.        MOV  R4,*R3+
  159.        MOV  R7,*R3+
  160.        MOV  R8,*R3+
  161.        MOV  R9,*R3+
  162.        CI   R1,SECBUF+512
  163.        JNE  POSI12
  164.  
  165. POSI13
  166. * Compute a pointer into the buffer by multiplying
  167. * the record within sector by the record size
  168.  
  169.        LDCR @B02,4
  170.        MOV  @4(R5),R1        Get FDR address
  171.        LDCR @2(R5),4         Select FDR bank
  172.        MOVB @17(R1),R0       Get record length
  173.        SRL  R0,8
  174.        MPY  R0,R10
  175.  
  176.        LDCR @B02,4
  177.        A    R11,@54(R5)      And add to buffer pointer
  178.        MOV  @POSIRT,R11      Restore return address
  179.        RT
  180.  
  181. POSI14 CI   R9,0
  182.        JEQ  POSI11
  183.        DEC  R9
  184.        MOV  R9,@52(R5)       Save sector within AU
  185.        AB   @B01,@54(R5)
  186.        LI   R1,SECBUF
  187.        JMP  POSI10
  188.